*Replication code for "Democracy and Documents" submission to R&P

*This file replicates the results included in the main text and appendix.

version 18.0
clear all
estimates clear

*Set command directory to location where replication files are saved.
*cd 

********************************************************************************
*PRETEST ANALYSIS
********************************************************************************
use "pretest.dta", clear

***Clean Data
*Check for and delete responses that do not meet the inclusion criteria. This includes:

	*Unfinished surveys
	tab finished
	
	*Non-consenting surveys
	tab consent
	drop if consent!=1
	tab consent
	
	*Participants flagged as bots by Qualtrics:
		*q_recaptchascore<0.5
		tab q_recaptchascore 
		
		*q_relevantidduplicatescore==1
		tab q_relevantidduplicatescore
		drop if q_relevantidduplicatescore!=0
		tab q_relevantidduplicatescore
		
		*q_relevantidfraudscore>=70
		tab q_relevantidfraudscore 
	
	*Participants using a VPS or otherwise not in the US
		*ip_block==1
		tab ip_block 

*Assess data quality via attention check
tab attention1 
		
***Create treatment and outcome variables
gen decision=.
local decisionvars security_decision economic_decision domestic_decision
	foreach d of local decisionvars {
		replace decision=1 if `d'==1
		replace decision=2 if `d'==2
		replace decision=3 if `d'==3
		replace decision=4 if `d'==4
		}
	tab decision

*For ease of analysis, create a binary version of the decision variable. Call it decisionbi.
gen decisionbi=.
	replace decisionbi=0 if decision==1|decision==2
	replace decisionbi=1 if decision==3|decision==4
tab decisionbi

*Create a dummy variable for each treatment condition. Call them security, economic, domestic.
gen security=0
	replace security=1 if security_decision==1|security_decision==2|security_decision==3|security_decision==4
tab security

gen economic=0
	replace economic=1 if economic_decision==1|economic_decision==2|economic_decision==3|economic_decision==4
tab economic

gen domestic=0
	replace domestic=1 if domestic_decision==1|domestic_decision==2|domestic_decision==3|domestic_decision==4
tab domestic

***Analysis
*Comparisons of proportion appropriate between treatment conditions (binary dv)
prtest decisionbi if security==1|economic==1, by(security) 
prtest decisionbi if security==1|domestic==1, by(security)
prtest decisionbi if economic==1|domestic==1, by(economic) 

*Comparisons of means appropriate between treatment conditions (4-point dv)
ttest decision if security==1|economic==1, by(security)
ttest decision if security==1|domestic==1, by(security)
ttest decision if economic==1|domestic==1, by(economic)

*Create Figure 1
mean decisionbi if security==1
	est store security
mean decisionbi if economic==1
	est store economic
mean decisionbi if domestic==1
	est store domestic
coefplot security economic domestic, vertical xlabel(none) /// 
	ylabel(0(.2)1) ytitle("Proportion Appropriate") /// 
	legend(rows(1)) scheme(s1mono) /// 
	note("Figure compares the proportions of respondents who viewed the decision to classify the document as" /// 
	"appropriate across treatment conditions with 95% confidence intervals. The figure uses a binary measure of" /// 
	"appropriateness and data from the survey pretest.", span)

********************************************************************************
*MAIN SURVEY ANALYSIS
********************************************************************************
*Load Data
use "mainsurvey.dta", clear

***Clean Data
*Check for and delete responses that do not meet the pre-registered inclusion criteria. This includes:
*consent
	tab consent
	drop if consent!=1
	tab consent
	
	*completed
	tab finished
	drop if finished!=1
	tab finished
	
	*attention screener
	tab attention1
	keep if attention1==3
	tab attention1
	
	*location requirements
	tab ip_block
	keep if ip_block==0
	tab ip_block
	
	tab ip_country
	keep if ip_country=="United States"
	tab ip_country
	
	*Qualtrics bot detection
	tab q_ballotboxstuffing 
	
	tab q_recaptchascore 
	
	tab q_relevantidduplicatescore 
	drop if q_relevantidduplicatescore>=75
	tab q_relevantidduplicatescore
	
	tab q_relevantidfraudscore 
	drop if q_relevantidfraudscore>=30
	tab q_relevantidfraudscore

*Assess data quality via second attention check
tab attention2

***Create Treatment and Outcome Variables

*Stage One: Confidence in institutions, binary
	tab institutions
	gen institutionsbi=.
		replace institutionsbi=0 if institutions==1|institutions==2
		replace institutionsbi=1 if institutions==3|institutions==4
	tab institutionsbi
	
*Stage One: Trust in president, binary
	tab trustpres
	gen trustpresbi=.
		replace trustpresbi=0 if trustpres==1|trustpres==2
		replace trustpresbi=1 if trustpres==3|trustpres==4
	tab trustpresbi

*Stage One: Trust in Congress, binary
	tab trustcongress
	gen trustcongressbi=.
		replace trustcongressbi=0 if trustcongress==1|trustcongress==2
		replace trustcongressbi=1 if trustcongress==3|trustcongress==4
	tab trustcongressbi

*Stage Two: Support for Firing
	*4-point scale
	gen fire=.
	local firevars fire_mil fire_fso
	foreach f of local firevars {
		replace fire=1 if `f'==1
		replace fire=2 if `f'==2
		replace fire=3 if `f'==3
		replace fire=4 if `f'==4
		}
	tab fire
	
	*Binary
		gen firebi=.
		replace firebi=0 if fire==1|fire==2
		replace firebi=1 if fire==3|fire==4
	tab firebi

*Stage Two: Trust Official
	*4-point scale
	gen trustofficial=.
	local trustvars trustmil trustdiplomat
	foreach t of local trustvars {
		replace trustofficial=1 if `t'==1
		replace trustofficial=2 if `t'==2
		replace trustofficial=3 if `t'==3
		replace trustofficial=4 if `t'==4
		}
	tab trustofficial
	
	*Binary
	gen trustofficialbi=.
		replace trustofficialbi=0 if trustofficial==1|trustofficial==2
		replace trustofficialbi=1 if trustofficial==3|trustofficial==4
	tab trustofficialbi
	
*Treatment Indicators
	tab handledtreat
	gen handled=0
		replace handled=1 if handledtreat=="correctly handled"
	tab handled
	
	gen mishandled=0
		replace mishandled=1 if handledtreat=="mishandled"
	tab mishandled
	
	gen military=0
		replace military=1 if fire_mil==1|fire_mil==2|fire_mil==3|fire_mil==4
	tab military
	
	gen diplomat=0
		replace diplomat=1 if fire_fso==1|fire_fso==2|fire_fso==3|fire_fso==4
	tab diplomat

*Pre-treatment confidence in institutions
	*Index
	gen conindex = (pretrust_1 + pretrust_2 + pretrust_3 + pretrust_4 + pretrust_5 + /// 
	pretrust_6 + pretrust_7)
	tab conindex
	
	*Index Quartiles
	xtile conquart=conindex, n(4)
	tab conquart
	
	*High prior confidence dummy
	gen highconfidence=.
		replace highconfidence=0 if conquart==1|conquart==2|conquart==3
		replace highconfidence=1 if conquart==4
	tab highconfidence
	
	*Low prior confidence dummy
	gen lowconfidence=.
		replace lowconfidence=0 if conquart==2|conquart==3|conquart==4
		replace lowconfidence=1 if conquart==1
	tab lowconfidence
	
	*Pre-treatment confidence in military
		*Scale
		tab pretrust_1

		*Binary
		gen pre_militarybi=.
			replace pre_militarybi=0 if pretrust_1==1|pretrust_1==2
			replace pre_militarybi=1 if pretrust_1==3|pretrust_1==4|pretrust_1==5
		tab pre_militarybi 
	
	*Pre-treatment confidence in diplomats
		*Scale
		tab pretrust_7
		
		*Binary
		gen pre_diplomatbi=.
			replace pre_diplomatbi=0 if pretrust_7==1|pretrust_7==2
			replace pre_diplomatbi=1 if pretrust_7==3|pretrust_7==4|pretrust_7==5
		tab pre_diplomatbi 
		
***Demographics
*partisanship
tab prespartisan

gen presdem=.
	replace presdem=0 if prespartisan=="Republican"
	replace presdem=1 if prespartisan=="Democrat"
tab presdem

gen presrep=.
	replace presrep=0 if prespartisan=="Democrat"
	replace presrep=1 if prespartisan=="Republican"
tab presrep

tab pid3
	tab piddem
	tab pidrep
	tab pidlean

	gen republican=.
		replace republican=1 if pid3==1|pidlean==2
		replace republican=0 if pid3==2|pidlean==1|pidlean==3
	tab republican //46%

	gen democrat=.
		replace democrat=1 if pid3==2|pidlean==1
		replace democrat=0 if pid3==1|pidlean==2|pidlean==3
	tab democrat //41%

	gen independent=.
		replace independent=1 if pidlean==3
		replace independent=0 if pid3==1|pid3==2|pidlean==1|pidlean==2
	tab independent //13%

gen copartisan=0
	replace copartisan=1 if presrep==1&republican==1
	replace copartisan=1 if presdem==1&democrat==1
tab copartisan

*Additional Demographics
tab gender
gen male=.
	replace male=1 if gender==2
	replace male=0 if gender==1|gender==3|gender==4
tab male

tab race
gen white=0
	replace white=1 if race=="1"|race=="1,2"|race=="1,2,3,5"|race=="1,3"
tab white

tab education
gen college=.
	replace college=0 if education==1|education==2|education==3|education==4
	replace college=1 if education==5|education==6
tab college

*Post-treatment attention to current events
tab currentevents_1
	rename currentevents_1 primaries
tab primaries

tab currentevents_2
	rename currentevents_2 biden
tab biden

tab currentevents_3
	rename currentevents_3 trump
tab trump

*Create attention index
gen currentindex = (primaries + biden + trump)
tab currentindex

*Index quartiles
xtile currentquart=currentindex, n(4)
	tab currentquart

*Dummy for high attention based on quartiles
gen highnews=.
	replace highnews=0 if currentquart==1|currentquart==2|currentquart==3
	replace highnews=1 if currentquart==4
tab highnews

*Use manipulation check to assess data quality
tab manip_handling mishandled, column

********************************************************************************
*Analysis reported in the main text

*Stage one comparisons of proportions by treatment condition
	*Confidence in institutions
	prtest institutionsbi, by(handled) 
	*Trust in president
	prtest trustpresbi, by(handled) 
	*Trust in Congress
	prtest trustcongressbi, by(handled)

*Figure 3. Public Confidence and Trust by Treatment Condition
mean institutionsbi if handled==1
	est store correct
mean institutionsbi if handled==0
	est store incorrect

coefplot correct incorrect, /// 
	vertical ciopts(recast(rcap)) xlabel(none) ylabel(0(0.2)1) /// 
	ytitle("Proportion Confident") title("Democratic Institutions") /// 
	scheme(s1mono) name(democracy)

mean trustpresbi if handled==1
	est store correct
mean trustpresbi if handled==0
	est store incorrect

coefplot correct incorrect, /// 
	vertical ciopts(recast(rcap)) xlabel(none) ylabel(0(0.2)1) /// 
	ytitle("Proportion Trust") title("President") /// 
	scheme(s1mono) name(presidency)

mean trustcongressbi if handled==1
	est store correct
mean trustcongressbi if handled==0
	est store incorrect

coefplot correct incorrect, /// 
	vertical ciopts(recast(rcap)) xlabel(none) ylabel(0(0.2)1) /// 
	ytitle("Proportion Trust") title("Congress") /// 
	scheme(s1mono) name(congressional)

graph combine democracy presidency congressional, /// 
	altshrink ycommon rows(1) iscale(1.5) scheme(s1mono) /// 
	note("The figure compares the proportions of post-treatment confidence in democratic institutions, trust in the" /// 
	"president, and trust in Congress, respectively, by treatment condition with 95% confidence intervals. The" /// 
	"figure uses binary measures of each variable, 4-point measures are reported in the appendix.", span)

*Exploratory Partisanship Analysis
	*Party ID
	*Differences in confidence between partisan subgroups
	prtest institutionsbi if democrat==1|republican==1, by(republican) 
	prtest institutionsbi if democrat==1|independent==1, by(independent) 
	prtest institutionsbi if republican==1|independent==1, by(republican) 
	
	*Confidence by treatment within each partisan subgroup
	prtest institutionsbi if democrat==1, by(handled)
	prtest institutionsbi if republican==1, by(handled)
	prtest institutionsbi if independent==1, by(handled) 
	
	*Copartisanship
	*Differences in confidence between copartisan and non subgroups
	prtest institutionsbi, by(copartisan)
	
	*Confidence by treatment within each copartisan subgroup
	prtest institutionsbi if copartisan==1, by(handled)
	prtest institutionsbi if copartisan==0, by(handled)
	
	*Figure 4. Partisan Subgroup Analysis
	*means by respondent party id
	mean institutionsbi if democrat==1
		est store Democrats
	mean institutionsbi if republican==1
		est store Republicans 
	mean institutionsbi if independent==1
		est store Independents
	
	coefplot Democrats Republicans Independents, /// 
		vertical ciopts(recast(rcap)) ylabel(0(0.2)1) xlabel(none) legend(rows(1)) /// 
		ytitle("Proportion Confident") title("Confidence by Party ID") /// 
		scheme(s1mono) name(pidmean)
	
	*treatment effects by respondent party id
	reg institutionsbi mishandled if democrat==1
		est store Democrats
	reg institutionsbi mishandled if republican==1
		est store Republicans
	reg institutionsbi mishandled if independent==1
		est store Independents
	
	coefplot Democrats Republicans Independents, keep(mishandled) /// 
		xline(0) xlabel(-0.4(0.1)0.1) xtitle("Change from Correctly Handled") /// 
		ylabel(none) legend(rows(1)) /// 
		title("Treatment Effect By Party ID") scheme(s1mono) name(pideffect)
	
	*means by copartisanship with president
	mean institutionsbi if copartisan==1
		est store copartisan
	mean institutionsbi if copartisan==0
		est store noncopartisan 
	
	coefplot copartisan noncopartisan, /// 
		vertical ciopts(recast(rcap)) ylabel(0(0.2)1) xlabel(none) legend(rows(1)) /// 
		ytitle("Proportion Confident") title("Confidence by Copartisanship") /// 
		scheme(s1mono) name(copartmean)
	
	*treatment effects by copartisanship
	reg institutionsbi mishandled if copartisan==1
		est store copartisan
	reg institutionsbi mishandled if copartisan==0
		est store noncopartisan 
	
	coefplot copartisan noncopartisan, keep(mishandled) /// 
		xline(0) xlabel(-0.4(0.1)0.1) xtitle("Change from Correctly Handled") /// 
		ylabel(none) legend(rows(1)) /// 
		title("Treatment Effect by Copartisanship") scheme(s1mono) name(coparteffect)

	graph combine pidmean pideffect copartmean coparteffect, /// 
		altshrink iscale(1.45) scheme(s1mono) /// 
		note("Figure reports the proportion of respondents confident in democratic institutions (left column) " /// 
		"and the effect of the incorrectly handled treatment relative to the correctly handled treatment (right column) " /// 
		"for each relevant subgroup, both with 95% confidence intervals. The relevant subgroups are party" /// 
		"identifications (top row) and copartisanship or non-copartisanship with the president (bottom row). ")


*Stage two results
	*Pre-treatment confidence in military vs. diplomats
	prtest pre_militarybi==pre_diplomatbi
	
	*Post-treatment trust in miltiary vs. diplomatic officials
	prtest trustofficialbi, by(military)
	
	*Post-treatment support for firing military vs. diplomatic officials
	prtest firebi, by(military)

	*Figure 5. Influence of Military Affiliations
	*pre-treatment trust
	mean pre_militarybi
		est store military
	mean pre_diplomatbi
		est store diplomats

	coefplot military diplomats, vertical xlabel(none) /// 
		ytitle("Proportion Confident") ylabel(0(0.2)1) /// 
		title("Pre-Treatment" "Confidence") scheme(s1mono) name(pretreat)

	*post-treatment trust
	mean trustofficialbi if military==1
		est store military
	mean trustofficialbi if diplomat==1
		est store diplomats

	coefplot military diplomats, vertical xlabel(none) /// 
		ytitle("Proportion Trust") ylabel(0(0.2)1) /// 
		title("Trust in""Officials Who Mishandled") /// 
		scheme(s1mono) name(post)

	*Support for Firing
	mean firebi if military==1
		est store military
	mean firebi if diplomat==1
		est store diplomats
	coefplot military diplomats, vertical xlabel(none) /// 
		ytitle("Proportion Support") ylabel(0(0.2)1) /// 
		title("Support for Firing""Officials Who Mishandled") /// 
		scheme(s1mono) name(fire)
	
	graph combine pretreat post fire, altshrink ycommon rows(1) /// 
		iscale(1.4) scheme(s1mono) /// 
		note("Figure reports comparisons of proportion for three measures with 95% confidence intervals." /// 
		"The first panel reports the proportions of pre-treatment confidence in the military and in U.S. diplomats." /// 
		"The second panel reports the proportions of post-treatment trust in the officials who mishandled documents," /// 
		"comparing the military and diplomat treatment conditions. The third panel reports the proportions of" /// 
		"post-treatment support for firing the officials who mishandled documents, comparing the military and" /// 
		"diplomat treatment conditions. All panels use binary measures of the relevant variable. The appendix" /// 
		"reports results using the 4-point measure.")

		
********************************************************************************
*Analysis included in appendix

*A5.1 Pre-treatment confidence in institutions
graph bar pretrust_1-pretrust_7, horizontal legend(label(1 "Military") label(2 "Police") /// 
	label(3 "Small Business") label(4 "The Presidency") label(5 "Congress") /// 
	label(6 "Supreme Court") label(7 "Diplomats")) blabel(bar) /// 
	ytitle("Level of Confidence") scheme(stmono1) /// 
	note("Figure includes the mean level of pre-treatment confidence in each actor from the main survey." /// 
	"Confidence was measured on a five-point scale ranging from 1 (none) to 5 (a great deal).", span)

*A5.2 Replication of main analyses using 4-point measures
*Figure A5.2 Public Confidence and Trust by Treatment COnditoin with 4-Point Measure
ttest institutions, by(mishandled)
ttest trustpres, by(mishandled)
ttest trustcongress, by(mishandled)

mean institutions if handled==1
	est store correct
mean institutions if handled==0
	est store incorrect

coefplot correct incorrect, /// 
	vertical ciopts(recast(rcap)) xlabel(none) /// 
	ytitle("Mean Confident") title("Democratic Institutions") /// 
	scheme(s1mono) name(democracy4)

mean trustpres if handled==1
	est store correct
mean trustpres if handled==0
	est store incorrect

coefplot correct incorrect, /// 
	vertical ciopts(recast(rcap)) xlabel(none) /// 
	ytitle("Mean Trust") title("President") /// 
	scheme(s1mono) name(presidency4)

mean trustcongress if handled==1
	est store correct
mean trustcongress if handled==0
	est store incorrect

coefplot correct incorrect, /// 
	vertical ciopts(recast(rcap)) xlabel(none) /// 
	ytitle("Mean Trust") title("Congress") /// 
	scheme(s1mono) name(congressional4)

graph combine democracy4 presidency4 congressional4, /// 
	altshrink ycommon rows(1) iscale(1.5) scheme(s1mono) /// 
	note("The figure compares the means of post-treatment confidence in democratic institutions, trust in the president," /// 
	"and trust in Congress, respectively, by treatment condition with 95% confidence intervals. The figure uses the" /// 
	"4-point scale measure of each variable, replicating Figure 3 from the main text.")

*Figure A5.3 Influence of Military Affiliation with 4-point measure
ttest pretrust_1==pretrust_7, unpaired
ttest trustofficial, by(military)
ttest fire, by(military)

	*pre-treatment trust
	mean pretrust_1
		est store military
	mean pretrust_7
		est store diplomats

	coefplot military diplomats, vertical xlabel(none) /// 
		ytitle("Mean Confident") title("Pre-Treatment" "Confidence") /// 
		scheme(s1mono) name(pretreat4)

	*post-treatment trust
	mean trustofficial if military==1
		est store military
	mean trustofficial if diplomat==1
		est store diplomats

	coefplot military diplomats, vertical xlabel(none) /// 
		ytitle("Mean Trust") title("Trust in""Officials Who Mishandled") /// 
		scheme(s1mono) name(post4)

	*Support for Firing
	mean fire if military==1
		est store military
	mean fire if diplomat==1
		est store diplomats

	coefplot military diplomats, vertical xlabel(none) /// 
		ytitle("Mean Support") title("Support for Firing""Officials Who Mishandled") /// 
		scheme(s1mono) name(fire4)
	
	graph combine pretreat4 post4 fire4, altshrink ycommon rows(1) /// 
		iscale(1.4) scheme(s1mono) /// 
		note("Figure reports comparisons of means for three measures with 95% confidence intervals." /// 
		"The first panel reports the means of pre-treatment confidence in the military and in U.S. diplomats." /// 
		"The second panel reports the mean levels of post-treatment trust in the officials who mishandled documents," /// 
		"comparing the military and diplomat treatment conditions. The third panel reports the mean levels of" /// 
		"post-treatment support for firing the officials who mishandled documents, comparing the military and" /// 
		"diplomat treatment conditions. All panels use 4-point measures of the relevant variable, replicating" /// 
		"Figure 5 from the main text.", span)

*A5.3 Are the stage two results conditional on stage one treatment assignment?
prtest firebi, by(mishandled)
prtest trustofficialbi, by(mishandled) 

	*Figure A5.4 Marginal Effects of Stage One Treatment Assignment on Stage Two Outcomes
	logit firebi i.military i.highconfidence military##highconfidence
		margins military, at(highconfidence=(0 1))
		marginsplot, scheme(s1mono) xtitle("High Pre-Treatment Confidence") /// 
		title("Predicted Probability of Support for Firing""by High Pre-Treatment Confidence") /// 
		name(predicthigh)
	logit firebi i.military i.lowconfidence military##lowconfidence
		margins military, at(lowconfidence=(0 1))
		marginsplot, scheme(s1mono) xtitle("Low Pre-Treatment Confidence") /// 
		title("Predicted Probability of Support for Firing""by Low Pre-Treatment Confidence") /// 
		name(predictlow)
	graph combine predicthigh predictlow, altshrink ycommon scheme(s1mono)

*A5.4 Tests for Additional Moderators
	*Figure A5.5 Marginal Effects of Republican Identification on Treatment
	logit institutionsbi i.mishandled i.republican mishandled##republican
		margins republican, at(mishandled=(0 1))
		marginsplot, xtitle("Incorrectly Handled Treatment") /// 
		title("Predicted Probabilities of""Confidence in Institutions by Party ID") /// 
		scheme(s1mono) name(predictparti)
	logit firebi i.military i.republican military##republican
		margins republican, at(military=(0 1))
		marginsplot, xtitle("Military Official Treatment") /// 
		title("Predicted Probabilities of""Support for Firing by Party ID") /// 
		scheme(s1mono) name(predictpartf)
	graph combine predictparti predictpartf, /// 
		altshrink ycommon rows(1) iscale(1.1) scheme(s1mono)
		
	*Figure A5.6 Marginal Effects of Copartisanship on Treatment
	logit institutionsbi i.mishandled i.copartisan mishandled##copartisan
		margins copartisan, at(mishandled=(0 1))
		marginsplot, xtitle("Incorrectly Handled Treatment") /// 
		title("Predicted Probabilities of""Confidence in Institutions by Copartisanship") /// 
		scheme(s1mono) name(predictcoi)
	logit firebi i.military i.copartisan military##copartisan
		margins copartisan, at(military=(0 1))
		marginsplot, xtitle("Military Official Treatment") /// 
		title("Predicted Probabilities of""Support for Firing by Copartisanship") /// 
		scheme(s1mono) name(predictcof)
	graph combine predictcoi predictcof, altshrink ycommon rows(1) iscale(1.1) scheme(s1mono)
	
	*Figure A5.7 Marginal Effects of Pre-Treatment Confidence on Treatment
	logit firebi i.military i.highconfidence military##highconfidence
		margins military, at(highconfidence=(0 1))
		marginsplot, scheme(s1mono) xtitle("High Pre-Treatment Confidence") /// 
		title("Predicted Probability of Support for Firing""by High Pre-Treatment Confidence") /// 
		name(predicthighpre)
	logit firebi i.military i.lowconfidence military##lowconfidence
		margins military, at(lowconfidence=(0 1))
		marginsplot, scheme(s1mono) xtitle("Low Pre-Treatment Confidence") /// 
		title("Predicted Probability of Support for Firing""by Low Pre-Treatment Confidence") /// 
		name(predictlowpre)
	graph combine predicthighpre predictlowpre, altshrink ycommon scheme(s1mono)
	
	*Figure A5.8 Marginal Effects of Attention to News on Treatment
	logit institutionsbi i.mishandled i.highnews mishandled##highnews
		margins highnews, at(mishandled=(0 1))
		marginsplot, xtitle("Incorrectly Handled Treatment") /// 
		title("Predicted Probabilities of""Confidence in Institutions by News Attention") /// 
		scheme(s1mono) name(newsconmargins)
	logit firebi i.military i.highnews military##highnews
		margins highnews, at(military=(0 1))
		marginsplot, xtitle("Military Official Treatment") /// 
		title("Predicted Probabilities of""Support for Firing by News Attention") /// 
		scheme(s1mono) name(newsmilmargins)

	graph combine newsconmargins newsmilmargins, altshrink ycommon rows(1) scheme(s1mono)

*A5.5 Estimating Treatment Effects with Demographic Controls
	*Confidence in Institutions
	reg institutionsbi mishandled male age democrat republican white college
	
	*Trust President
	reg trustpresbi mishandled male age democrat republican white college

	*Trust Congress
	reg trustcongressbi mishandled male age democrat republican white college

	*Support Firing
	reg firebi military male age democrat republican white college
	
	*Trust Officials
	reg trustofficialbi military male age democrat republican white college

*A5.6 Estimating Treatment Effects in Gender and Age Subgroups
	
*Age
	*Create new dummy variable for respondents >=55
	tab age
	gen older=.
		replace older=1 if age==5|age==6|age==7|age==8
		replace older=0 if age==1|age==2|age==3|age==4
	tab older
	
	reg institutionsbi handled older handled##older
	
	*Treatment effects among "older" subgroup
	prtest institutionsbi if older==1, by(handled)
	prtest trustpresbi if older==1, by(handled)
	prtest trustcongressbi if older==1, by(handled)
	
	*Treatment effects among "younger" subgroup
	prtest institutionsbi if older==0, by(handled)
	prtest trustpresbi if older==0, by(handled)
	prtest trustcongressbi if older==0, by(handled)
	
	*Figure of treatment effect on confidence in institutions for each age subgroup
	*Older subgroups
	mean institutionsbi if older==1&handled==1
		est store correct_older
	mean institutionsbi if older==1&handled==0
		est store incorrect_older
	coefplot correct_older incorrect_older, /// 
		vertical ciopts(recast(rcap)) xlabel(none) ylabel(0(0.2)1) /// 
		ytitle("Proportion Confidence") title("Older Subgroup") /// 
		scheme(s1mono) name(old)

	*Younger Subgroups
	mean institutionsbi if older==0&handled==1
		est store correct_younger
	mean institutionsbi if older==0&handled==0
		est store incorrect_younger
	coefplot correct_younger incorrect_younger, /// 
		vertical ciopts(recast(rcap)) xlabel(none) ylabel(0(0.2)1) /// 
		ytitle("Proportion Confidence") title("Younger Subgroup") /// 
		scheme(s1mono) name(young)
	
	graph combine old young, altshrink ycommon scheme(s1mono)

*Gender
	tab male
	
	reg institutionsbi handled male handled##male
	
	*Treatment effects among women
	prtest institutionsbi if male==0, by(handled)
	prtest trustpresbi if male==0, by(handled)
	prtest trustcongressbi if male==0, by(handled)
	
	*Treatment effects among men
	prtest institutionsbi if male==1, by(handled)
	prtest trustpresbi if male==1, by(handled)
	prtest trustcongressbi if male==1, by(handled)
	
	*Figure of treatment effect on confidence in institutions for each gender subgroup
	*male subgroups
	mean institutionsbi if male==1&handled==1
		est store correct_men
	mean institutionsbi if male==1&handled==0
		est store incorrect_men
	coefplot correct_men incorrect_men, /// 
		vertical ciopts(recast(rcap)) xlabel(none) ylabel(0(0.2)1) /// 
		ytitle("Proportion Confidence") title("Men Subgroup") /// 
		scheme(s1mono) name(men)

	*women Subgroups
	mean institutionsbi if male==0&handled==1
		est store correct_women
	mean institutionsbi if male==0&handled==0
		est store incorrect_women
	coefplot correct_women incorrect_women, /// 
		vertical ciopts(recast(rcap)) xlabel(none) ylabel(0(0.2)1) /// 
		ytitle("Proportion Confidence") title("Women Subgroup") /// 
		scheme(s1mono) name(women)
	
	graph combine men women, altshrink ycommon scheme(s1mono)
		
		
